# Contributor: John Regan <john@jrjrtech.com>
# Maintainer: Laurent Bercot <ska-devel@skarnet.org>
pkgname=s6-dns
pkgver=2.3.7.1
pkgrel=0
pkgdesc="skarnet.org's DNS client libraries and command-line DNS client utilities"
url=https://skarnet.org/software/s6-dns/
arch="all"
license="ISC"
options="!check"
makedepends="skalibs-dev>=2.14"
subpackages="$pkgname-static $pkgname-dev $pkgname-doc"
source="https://skarnet.org/software/s6-dns/s6-dns-$pkgver.tar.gz s6-dns.pc"

prepare() {
	default_prepare
	sed -i -e "s/@@VERSION@@/$pkgver/g" -- "$srcdir"/*.pc
}

build() {
	./configure \
		--enable-shared \
		--enable-static \
		--disable-allstatic \
		--prefix=/usr \
		--libdir=/usr/lib \
		--libexecdir="/usr/lib/$pkgname" \
		--with-dynlib=/lib
	make
}

package() {
	make DESTDIR="$pkgdir" install
	install -D -m644 "$srcdir/s6-dns.pc" "$pkgdir/usr/lib/pkgconfig/s6-dns.pc"
}

doc() {
	default_doc
	mkdir -p "$subpkgdir/usr/share/doc"
	cp -a "$builddir/doc" "$subpkgdir/usr/share/doc/$pkgname"
}

static() {
	default_static
	rmdir -p "$pkgdir"/usr/lib/"$pkgname" || :
}

sha512sums="
9dabee86d9a27fb0e4a3c10563694bb5734c08c4d730a69daec17dad140274aa104bd6edbd501261c7a7c7bcee505f79134b7119457d5fbedcbb2be6b352ebb0  s6-dns-2.3.7.1.tar.gz
2b285cf8691ad30e8ada115d2ee81b4d356eda042b0ab18cf3006069707963bedc922c9f3bf2051c11e4abc30abed2932fd6c3f1f8d4e0d54bf11e30c3741090  s6-dns.pc
"
